#ifndef STACK_C
#define STACK_C

int stackSegment;
int stackPointer;
uint32_t basePointer;
int* CallStack;
int CallStackPointer;

uint32_t stackalloc(uint32_t size)
{
	basePointer += size;
	stackPointer += size;
	return basePointer;
}
void pushQword(uint64_t dword)
{
	stackPointer += 8;
	((uint64_t*)(RAM + (basePointer - stackPointer)))[0] = dword;
	
}

 /*
  * Push a dword (32 bit unsigned integer)
  * onto the stack
  */
void pushDword(uint32_t dword)
{
	stackPointer += 4;
	((uint32_t*)(RAM + (basePointer - stackPointer)))[0] = dword;	
}

/*
 * Pushes a word (16 bit unsigned integer)
 * onto the stack
 */
 
void pushWord(uint16_t  word)
{
	stackPointer += 2;
	((uint16_t*)(RAM + (basePointer - stackPointer)))[0] = word;
}

/*
 * Pushes a byte (8 bit unsigned integer)
 * on to the stack
 */

void pushFloat(float  dword)
{
	stackPointer += 4;
	((float*)(RAM + (basePointer - stackPointer)))[0] = dword;
}
void pushByte(unsigned char Byte)
{
	stackPointer++;
	RAM[(basePointer - stackPointer)] = Byte;
}

uint64_t popInt64()
{
	uint64_t i = ((uint64_t*)(RAM + (basePointer - stackPointer)))[0];
	stackPointer = stackPointer - 8;
	return i;
	
}


uint32_t popInt32()
{
	uint32_t i = ((uint32_t*)(RAM + (basePointer - stackPointer)))[0];
	stackPointer -= 4;
	return i;

}

float popFloat()
{
	float i = ((float*)(RAM + (basePointer - stackPointer)))[0];
	stackPointer -= 4;
	return i;

}

uint16_t popInt16()
{
	uint16_t i = ((uint16_t*)(RAM + (basePointer - stackPointer)))[0];
	stackPointer = stackPointer - 2;
	return i;


}

unsigned char popInt8()
{
	stackPointer--;
	return RAM[ (basePointer - stackPointer) - 1 ];


}

#endif
